package com.chang.resourceTest;

import org.springframework.core.io.UrlResource;

import java.io.IOException;
import java.net.MalformedURLException;

// urlResource访问网络资源
public class UrlResourceDemo {

    public static void main(String[] args) throws IOException {
        loadURL("http://www.baidu.com");
    }

    //访问前缀为 http，file开头
    public static void loadURL(String path) throws IOException {
        // 创建Resource实现类的对象 UrlResource
        UrlResource url = new UrlResource(path);

        // 获取资源信息
        System.out.println(url.getURL());
        System.out.println(url.getFilename());
        System.out.println(url.getDescription());
        System.out.println(url.getInputStream().read());
    }
}
